<template>
		<view class="point"  @touchmove.prevent.stop="setTouchMove" :style="'top:'+top+'px;'">
			<image src="https://yi.qj361.com/20210605110622_悬浮.gif" @click="gopoint"></image>	
		</view>
	</view>
</template>

<script>
	let height = uni.getSystemInfoSync().windowHeight;
	let movetop = uni.getSystemInfoSync().statusBarHeight;
	import Authorization from '@/pages/authorization/index'
	import {
		login,
		authorize
	} from '@/utils'
	import {
		mapGetters
	} from 'vuex'
	export default{
		name:'Point', 
		prop:{
			Authorization,
		},
		data(){
			return{ 
				top:390,
				moveMaxHeight:height-movetop-85,
			}
		},
		watch:{
			
		},
		created() {
			
		},
		computed: mapGetters(['userInfo']),
		mounted() {
			
		},
		methods: {
			setTouchMove: function (e) {
			    var that = this;
				//px和rpx的换算
				
				
			    if (e.touches[0].clientY < that.moveMaxHeight && e.touches[0].clientY > 66) {   
					e.preventDefault();
			        that.top = e.touches[0].clientY;
			    }
				return;
			 },
			 gopoint:function(){
				 if(this.userInfo.uid){
					 if (this.userInfo.agent === 1 && this.userInfo.agent === 2) {
					      this.$yrouter.push({
					       path: '/pages/shop/Goodsduihuan/index'
					      });
					   } 
					 else if(this.userInfo.agent === 3 ){  
					    this.$yrouter.push({
					 	  path: '/pages/shop/Goodsduihuan/indexcode'
					 	 });
					 }
					 else{
						 this.$yrouter.push({
						  path: '/pages/shop/Goodsduihuan/index'
						 }); 
					 }
				 }else{
					  
					 wx.getUserProfile({
					 	lang: 'zh_CN', 
					 	desc: '需要获取您的信息用来展示',
					 	success: res => {
					 		console.log(res)
					 		uni.showLoading({
					 			title: '登录中',
					 		})
					 		login(res)
					 			.then(e => {
					 				console.log(this.userInfo);
					 				if (this.userInfo.agent === 1 && this.userInfo.agent === 2) {
					 				     this.$yrouter.push({
					 				      path: '/pages/shop/Goodsduihuan/index'
					 				     });
					 				  } 
					 				if(this.userInfo.agent === 3 ){
					 				   this.$yrouter.push({
					 					  path: '/pages/shop/Goodsduihuan/indexcode'
					 					 });
					 				}
					 				// console.log('重定向')
					 				// this.$yrouter.reLaunch({
					 				// 	path: cookie.get('redirect').replace(/\ /g, ''),
					 				// })
					 				// 获取用户信息身份 
					 			})
					 			.catch(error => {
					 				console.log(error)
					 				uni.showToast({
					 					title: error,
					 					icon: 'none',
					 					duration: 2000,
					 				})
					 			})
					 	},
					 })
					 
					 
				 }	 
			 },
		}
	}
</script>

<style lang="scss">
	.point{
		width:200rpx;
		height:190rpx;
		position:fixed;
		right:0rpx;
		z-index:999;
		image{
			width:100%;
			height:100%;
		}
	}
</style>
